﻿//https://ac.nowcoder.com/acm/problem/227309

#include <iostream>
#include <string>
 using namespace std;
 int t, n, k;
 string s;

int fun()
{
	int ret = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'L')
		{
			ret--;
		}
		else
		{
			if (i - 1 >= 0 && i - 2 >= 0 && s[i - 1] == 'W' && s[i - 2] == 'W')
			{
				ret += k;
			}
			else
			{
				ret += 1;
			}
		}
	}
	return ret;
}
int main()
{
	cin >> t;
	while (t--)
	{
		cin >> n >> k >> s;
		cout << fun() << endl;
	}

	return 0;
}

//https://www.nowcoder.com/practice/b56799ebfd684fb394bd315e89324fb4?tpId=196&tqId=37149&ru=/exam/oj
class Solution
{
	int hash[100010] = { 0 };
public:
	int maxLength(vector<int>& arr)
	{
		int left = 0, right = 0, n = arr.size();
		int ret = 0;
		while (right < n)
		{
			hash[arr[right]]++; // 进窗⼝
			while (hash[arr[right]] > 1) // 判断
			{
				hash[arr[left]]--; // 出窗⼝
				left++;
			}
			ret = max(ret, right - left + 1); // 更新结果
			right++;
		}
		return ret;
	}
};

//https://ac.nowcoder.com/acm/problem/222104

#include <iostream>
using namespace std;
const int N = 100010;
int n;
char s[N];
char ret[N];
int main()
{
	cin >> n >> s;

	int hash[26] = { 0 }; // 统计每个字符的频次
	int maxIndex, maxCount = 0;
	for (int i = 0; i < n; i++)
	{
		if (maxCount < ++hash[s[i] - 'a'])
		{
			maxCount = hash[s[i] - 'a'];
			maxIndex = s[i] - 'a';
		}
	}

	if (maxCount > (n + 1) / 2) cout << "no" << endl;
	else
	{
		cout << "yes" << endl;
		int index = 0;
		// 先去摆放出现次数最多的
		while (maxCount--)
		{
			ret[index] = maxIndex + 'a';
			index += 2;
		}
		// 处理剩下的
		for (int i = 0; i < 26; i++)
		{
			if (hash[i] && i != maxIndex)
			{
				while (hash[i]--)
				{
					if (index >= n) index = 1;
					ret[index] = i + 'a';
					index += 2;
				}
			}
		}
		// 打印结果
		for (int i = 0; i < n; i++) cout << ret[i];
		cout << endl;
	}

	return 0;
}
